<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------

namespace Home\Controller;
use OT\DataDictionary;

/**
 * 前台首页控制器
 * 主要获取首页聚合数据
 */
class IndexController extends HomeController {

	//系统首页
    public function index(){
        // variables
        $category = D('Category')->getTree();
        $lists = D('Document')->lists(null);
        $caroImg = M('DocumentCaroimgs')->join('opto_lab_document ON opto_lab_document_caroimgs.id=opto_lab_document.id')->where("status=1")->order("level desc")->select();
        $lab_brief = M('Document')->where("id=3")->getField("description");
        $lab_img = get_cover(M('Document')->where("id=3")->getField("cover_id"),"path");
        $last_news = M('Document')->alias("a")->join("opto_lab_category b ON a.category_id=b.id")->where("(category_id=46 OR category_id=47) AND a.status=1")->order("a.id desc")->field("a.id as id, a.title as art_title, b.title as cat_title, b.name as cat_name,a.create_time as create_time")->limit(5)->select();

        $this->assign('category',$category);//栏目
        $this->assign('lists',$lists);//列表
        $this->assign('page',D('Document')->page);//分页
        $this->assign('lab_img',$lab_img); 
        $this->assign('caroImg', $caroImg);
        $this->assign('lab_brief', $lab_brief);
        $this->assign('last_news', $last_news);

        $this->display();
    }
}